package com.ncst.backend.service.impl;

import com.ncst.backend.domain.DrugLibrary;
import com.ncst.backend.mapper.DrugLibraryMapper;
import com.ncst.backend.service.DrugLibraryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class DrugLibraryServiceImpl implements DrugLibraryService {

    private final DrugLibraryMapper mapper;

    @Override
    public List<DrugLibrary> search(String key, String category) {
        return mapper.search(key, category);
    }

    @Override
    public boolean save(DrugLibrary drug) {
        return mapper.insert(drug) > 0;
    }

    @Override
    public boolean updateById(DrugLibrary drug) {
        return mapper.updateById(drug) > 0;
    }

    @Override
    public boolean removeById(Integer id) {
        return mapper.deleteById(id) > 0;
    }
}